#include <bits/stdc++.h>
#define rep(i,l,r) for (int i = l; i <= r; i ++)
#define per(i,r,l) for (int i = r; i >= l; i --)
using namespace std;
const int MN = 1e6 + 5;
int n,m,k,cnt,sum,ans,pos;
struct P {
	int st,ed;
	bool operator < (const P x) const {
		return ed > x.ed;
	}
}a[MN],b[MN];
bool cmp (P x,P y) {
	return x.st < y.st || x.st == y.st && x.ed < y.ed;
}
priority_queue<P>Q;
int main () {
	freopen ("airport.in","r",stdin);
    freopen ("airport.out","w",stdout);
	scanf ("%d%d%d",&k,&n,&m);
	rep (i,1,n) scanf ("%d%d",&a[i].st,&a[i].ed);
	rep (i,1,m) scanf ("%d%d",&b[i].st,&b[i].ed);
	sort (a + 1,a + 1 + m,cmp);
	sort (b + 1,b + 1 + m,cmp);
	rep (i,1,k) {
		sum = cnt = 0;
		while (! Q.empty()) Q.pop ();
		rep (j,1,n) {
			if (cnt < i) Q.push (a[j]),sum ++,cnt ++;
			else if (Q.top ().ed < a[j].st) Q.pop (),Q.push (a[j]),sum ++; 
		}
		while (! Q.empty()) Q.pop ();
		cnt = 0;
		rep (j,1,m) {
			if (cnt < (k - i)) Q.push (b[j]),sum ++,cnt ++;
			else if (Q.top ().ed < b[j].st) Q.pop (),Q.push (b[j]),sum ++; 
		}
		if (sum > ans) ans = sum,pos = i;
	} 
	cout << ans ;
	return 0;
}
/*3 5 4
1 5
3 8
6 10
9 14
13 18
2 11
4 15
7 17
12 16*/
